
/*
'===============================================================================
'  Generated From - BLL_Component_Partial_Core.vbgen
'  
'  This object is partial class component representing a table in a database. It
'  contains core data access methods. Other partial classes should be used for 
'  implementing custom business logic. This class can be regenerated many times.
'  
'  Do not write custom business logic in this class as it will be overwritten 
'  next time the class is generated.
'
'  Version: 1.0
'  Date:	30/01/06
'  Summary: SelectOne, SelectAll, SelectAllWForeignKey, Insert, Update, Delete,
'  			DeleteAllWForeignKey, class for sorting.
'===============================================================================
*/
using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
    [DataObjectAttribute]
	public partial class vwVenueContactWVenueNameComponent
    {
        
		/// <summary>
        /// Default constructor.
        /// </summary>
		public vwVenueContactWVenueNameComponent()
        {

        }

	
		/// <summary>
        /// Selects all records from the database table.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
		[DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
		public List<vwVenueContactWVenueName> SelectAll(string sortExpression)
        {
            List<vwVenueContactWVenueName> listvwVenueContactWVenueName = new List<vwVenueContactWVenueName>();
            PlacementManager.DAL.vwVenueContactWVenueName_DAL o = new PlacementManager.DAL.vwVenueContactWVenueName_DAL();

            DataSet ds = o.SelectAll();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listvwVenueContactWVenueName.Add(new vwVenueContactWVenueName((int)row["VenueContactId"], (int)row["VenueId"], (int)row["ContactId"], (bool)row["IsActive"], (string)row["VenueName"]));
            }
			
			if (sortExpression == string.Empty)
            {
                sortExpression = "DateCreated desc";
            }

            listvwVenueContactWVenueName.Sort(new vwVenueContactWVenueNameComparer(sortExpression));
            return listvwVenueContactWVenueName;
        }
	}
	
	public class vwVenueContactWVenueNameComparer : IComparer<vwVenueContactWVenueName>
    {
        private string _sortColumn;
        private bool _reverse;

        public vwVenueContactWVenueNameComparer(string sortExpression)
        {
            _reverse = sortExpression.ToLowerInvariant().EndsWith(" desc");
            if (_reverse)
            {
                _sortColumn = sortExpression.Substring(0, sortExpression.Length - 5);
            }
            else
            {
                _sortColumn = sortExpression;
            }
        }

        public int Compare(vwVenueContactWVenueName a, vwVenueContactWVenueName b)
        {
            int retVal = 0;
            switch (_sortColumn)
            {
				case "VenueContactId":
					retVal = String.Compare(a.VenueContactId.ToString(), b.VenueContactId.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "VenueId":
					retVal = String.Compare(a.VenueId.ToString(), b.VenueId.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "ContactId":
					retVal = String.Compare(a.ContactId.ToString(), b.ContactId.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "IsActive":
					retVal = String.Compare(a.IsActive.ToString(), b.IsActive.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;
				case "VenueName":
					retVal = String.Compare(a.VenueName.ToString(), b.VenueName.ToString(), StringComparison.InvariantCultureIgnoreCase);
					break;

            }
            return (retVal * (_reverse ? -1 : 1));
        }
    }
}
	
